/**
 * 
 */
package com.thor.palmmall.rest.chart.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.palmmall.rest.chart.AReceiptReport;
import com.thor.palmmall.spi.chart.SReceiptReport;

/**
 * @author NuoSa
 *
 * @since 1.0
 */
public class AReceiptReportConverter implements Converter<SReceiptReport, AReceiptReport> {

  public static AReceiptReportConverter getInstance() {
    if (instance == null)
      instance = new AReceiptReportConverter();
    return instance;
  }

  private static AReceiptReportConverter instance;

  private AReceiptReportConverter() {
  }

  @Override
  public AReceiptReport convert(SReceiptReport source) {
    if (source == null) {
      return null;
    }
    AReceiptReport target = new AReceiptReport();
    target.setSettle(source.getSettle());
    target.setDebt(source.getDebt());
    target.setRate(source.getRate());
    target.setReceivable(source.getReceivable());
    target.setReceived(source.getReceived());
    target.setStore(UCN.newInstance(source.getStore()));
    return target;
  }

}
